<?php
$db_connect = mysqli_connect("localhost", "root", "", "battleofthemages");
session_start();

$users = array();

$onlineQuery = "SELECT username FROM user WHERE is_online=1";
$result = mysqli_query($db_connect, $onlineQuery);
if(mysqli_num_rows($result) > 0){
    while($row = mysqli_fetch_assoc($result)){
        $username = $row['username'];
        $users[] = "<option value=\"" . $row['username'] . "\">" . $row['username'] . "</option>";
    }
}

echo json_encode($users);

mysqli_close($db_connect);
?>